#include "apue.h"
#include "error.c"
#include <dirent.h>
#include <fcntl.h>

#define BUFFSIZE 4096

int main(int argc, char const *argv[])
{
    int n;
    char buf[BUFFSIZE];
    
    while((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0){
        if((val = fcntl(STDOUT_FILENO, F_GETFL, 0)) < 0)
            err_sys("get file status flag error.");
        if(write(STDOUT_FILENO, buf, n) != n)
            err_sys("write error");
    }
    if(n < 0)
        err_sys("read error");
    return 0;
}
